package com.lm.easyexcel.controller;
import com.alibaba.excel.EasyExcel;
import com.lm.easyexcel.entry.UserData;
import com.lm.easyexcel.listener.UserDataListener;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/excel")
public class ExcelController {

    @PostMapping("/upload")
    public String uploadExcel(@RequestParam("file") MultipartFile file) throws Exception {
        EasyExcel.read(file.getInputStream(), UserData.class, new UserDataListener())
                .sheet()
                .doRead();
        return "Excel 导入成功！";
    }
}